Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 9, 2025

This PR implements Docker base image caching to significantly reduce build times by storing the time-consuming npm dependencies installation step as a reusable image.

Changes Made

Modified on_call_build_site.yaml: Added push_tag input parameter and two new steps:

  • Build base image (ghcr.io/orionrobots/orionrobots-site.base) before the main site build
  • Conditionally push the base image only after all other build stages complete successfully

Modified on_push_to_master_test_and_deploy.yaml: Added push_tag: "latest" to cache base images for the main branch and updated action dependencies.

Modified on_pr_test.yaml: Added intelligent change detection using tj-actions/changed-files to only push base images when relevant files change (Dockerfile, package.json/lock, workflows).

Updated action dependencies: Replaced stale dorny/paths-filter action with actively maintained tj-actions/changed-files v44.5.7 across all workflows.

Build Process Flow

  1. Always builds the base image (containing npm dependencies) for use in subsequent stages
  2. Conditionally pushes the base image only when:
    • Push to master → tagged as latest
    • PR with relevant file changes → tagged with PR number
    • Failed builds never push (push step runs last)

Smart Change Detection

The PR workflow detects changes to base image-affecting files:

  • Dockerfile
  • package.json / package-lock.json
  • Workflow files themselves

Only PRs modifying these files will push a new base image, avoiding unnecessary registry bloat.

Benefits

  • Significant time savings: The expensive npm ci step (taking 3+ minutes) is now cached and reusable
  • Efficient storage: Only pushes images when actually needed
  • Build reliability: Failed builds cannot push corrupted images
  • Security: Uses pinned action versions with SHA references
  • Maintainability: Uses actively maintained tj-actions/changed-files instead of stale dorny/paths-filter

Fixes #255.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: dannystaple <426859+dannystaple@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Push the base image after it's creation Add Docker base image caching to reduce build times Aug 9, 2025
@Copilot Copilot AI requested a review from dannystaple August 9, 2025 11:34
Copilot finished work on behalf of dannystaple August 9, 2025 11:34
- uses: actions/checkout@v4

- name: Check for base image related changes
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot This action has not had any updates in some time and might be a bit stale. Can we use https://github.com/tj-actions/changed-files instead please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! I've replaced all instances of dorny/paths-filter with tj-actions/changed-files v44.5.7 in both the PR test workflow and the master deploy workflow. The functionality remains the same but now uses the actively maintained action with SHA pinning for security. Commit a8e9bf6.

Co-authored-by: dannystaple <426859+dannystaple@users.noreply.github.com>
@Copilot Copilot AI requested a review from dannystaple August 9, 2025 11:58
Copilot finished work on behalf of dannystaple August 9, 2025 11:58
Copy link
Contributor

github-actions bot commented Aug 9, 2025

🦙 MegaLinter status: ❌ ERROR

Descriptor Linter Files Fixed Errors Warnings Elapsed time
❌ ACTION actionlint 5 6 0 0.08s
✅ BASH bash-exec 1 0 0 0.0s
✅ BASH shellcheck 1 0 0 0.06s
⚠️ BASH shfmt 1 1 0 0.0s
❌ C cppcheck 8 8 0 0.29s
❌ CPP cppcheck 8 8 0 0.29s
✅ JSON npm-package-json-lint yes no no 0.48s
✅ JSON v8r 12 0 0 9.35s
❌ MARKDOWN markdown-link-check 737 214 0 54.12s
✅ REPOSITORY gitleaks yes no no 13.85s
✅ REPOSITORY git_diff yes no no 0.53s
❌ REPOSITORY grype yes 2 no 34.38s
✅ REPOSITORY secretlint yes no no 41.77s
✅ REPOSITORY syft yes no no 1.38s
✅ REPOSITORY trivy-sbom yes no no 3.2s
✅ REPOSITORY trufflehog yes no no 4.72s
✅ XML xmllint 1 0 0 190.08s
✅ YAML v8r 13 0 0 6.81s

See detailed report in MegaLinter reports

MegaLinter is graciously provided by OX Security

@dannystaple dannystaple marked this pull request as ready for review August 9, 2025 15:49
@dannystaple dannystaple merged commit 838a0c8 into master Aug 9, 2025
5 checks passed
@dannystaple dannystaple deleted the copilot/fix-255 branch August 9, 2025 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Push the base image after it's creation
2 participants